package com.pug.web.minio;

import com.pug.config.minio.MinIOConfig;
import com.pug.config.minio.MinIoUploadService;
import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * Author: lqm
 * create: 2022/3/20 14:28
 * Lover: lqx
 *
 * @see
 */
@Controller
public class MyMinio {
    @Resource
    MinIoUploadService minIoUploadService;
    @Resource
    MinIOConfig minIOConfig;
    public String fileUpload(MultipartFile file) throws Exception {
        String fileName=file.getOriginalFilename();
        minIoUploadService.uploadFile("bucketName",fileName,file.getInputStream());
        String imgUrl = minIOConfig.getFileHost()
                + "/"
                + minIOConfig.getBucketName()
                + "/"
                + fileName;
        return imgUrl;
    }
}
